
{extend name='public/base' /}

{block name="content"}

<div class="layui-col-md12">
    <div class="layui-card">

        <div class="layui-card-body">
            <div class="layui-form">

                <a  class="layui-btn" href="javascript:;" autocomplete="off"> 数据库还原  </a>
                <table class="layui-table">
                    <thead>
                    <tr>
                        <th>数据库名称</th>
                        <th>卷数</th>
                        <th>压缩</th>
                        <th>数据大小</th>
                        <th>备份时间</th>
                        <th>状态</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    {foreach name='list' item='data'}
                    <tr>
                        <td>{$data.time|ftime}</td>
                        <td>{$data.part}</td>
                        <td>{$data.compress}</td>
                        <td>{$data.size|format_bytes}</td>
                        <td>{$key}</td>
                        <td class="status">-</td>
                        <td class="action">
                            <a class="db-down layui-btn layui-btn-xs layui-btn-normal" href="{:url('DataBackup/down',['time'=>$data['time']])}">下载</a>&nbsp;
                         <!--   <a class="db-import" href="{:url('DataBackup/import',['time'=>$data['time']])}">还原</a>&nbsp;-->
                            <a class="ajax-get confirm layui-btn layui-btn-xs " href="{:url('DataBackup/del',['time'=>$data['time']])}">删除</a>
                        </td>
                    </tr>
                    {/foreach}
                    </tbody>

                </table>

            </div>

        </div>
    </div>

</div>

{/block}

{block name="js"} <!--js处理区-->

<script>
    layui.use(['jquery','layer'],function(){
        window.$ = layui.$;
        var layer = layui.layer;

        $(".db-import").click(function(){
            var self = this, status = ".";
            $(this).parent().prevAll('.status').html("").html('等待还原');

            $.get(self.href, success, "json");
            window.onbeforeunload = function(){ return "正在还原数据库，请不要关闭！" }
            return false;

            function success(data){
                if(data.code==1){
                    $(self).parent().prev().text(data.msg);
                    if(data.data.part){
                        $.get(self.href,
                            {"part" : data.data.part, "start" : data.data.start},
                            success,
                            "json"
                        );
                    }  else {
                        layer.alert(data.msg);
                        //window.onbeforeunload = function(){ return null; }
                    }
                } else {
                    layer.alert(data.msg);
                }
            }
        });
    });

</script >


{/block}
